#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main()
{
	int i,j;
	int column;
	int row;

	cout << "Enter Number of Rows: ";
	cin >> row;

	cout << endl << "Enter Number of Columns: ";
	cin >> column;

	if(row < 1 || column < 1)
	{
		if(row < 1)
		{
			row = 1;
			cout << "Invalid Input for Rows\nUsing default value 1\n";
		}
		if(column < 1)
		{
			column = 1;
			cout << "Invalid Input for Column\nUsing default value 1\n";
		}
	}
	else if(row > 20 || column > 20)
	{
		if(row > 20)
		{
			row = 20;
			cout << "Invalid Input for Rows\nUsing default value 20\n";
		}
		if(column > 20)
		{
			column = 20;
			cout << "Invalid Input for Column\nUsing default value 20\n";
		}
	}

	i = 1;
	while(i <= row)
	{
		j = 1;
		while(j <= column)
		{
			if(i == 1 || i == row)
			{
				cout << "*";
				j++;
			}
			else
			{
				cout << "*";
				for(int k = 1; k < column - 1; k++)
				{
					cout << " ";
				}
				cout << "*";
				j = column + 1;//breaks out of inner while loop
			}
		}
		cout << endl;
		i++;
	}
	cin.get();
	cin.get();//Pauses code at end
	return 0;
}